# on node env
FROM node:18-alpine as builder

WORKDIR /app

# layer one
ADD package.json package-lock.json /app/
RUN npm i

# layer two
ADD . /app
RUN npm run build

# on nginx env
FROM nginx:alpine
COPY --from=builder app/dist /usr/share/nginx/html
COPY --from=builder app/nginx/nginx.conf /etc/nginx/nginx.conf

# export port
EXPOSE 3000

CMD ["nginx", "-g", "daemon off;"]
